<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>用户登录页</title>
    <link rel="stylesheet" href="/css/bootstrap.min.css">
    <script src="/js/jquery-3.6.1.min.js"></script>
    <script src="/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="/css/user.css">

</head>
<body>
    <div id="big_box"><!-- 大盒子，包揽全部内容 -->
        <label id="content">欢迎登录</label>
        <label for="username"></label>
        <input id="username" type="text" placeholder="用户名" name="username"><!-- 用户名 -->
        <label for="password"></label>
        <input id="password" type="password" placeholder="密码" name="password"><!-- 密码 -->
        <button type="button" id="login" onclick="login()">登录</button>
    </div>
<script type="text/javascript">
    function login(){
        var name=$("#username").val();
        var password=$("#password").val();
        $.ajax({
            url:"/webapi/login/user",
            data:{
                name:name,
                password:password
            }
        }).done(function (rs){
            if(rs>=0){
                //成功
                window.location.href="http://localhost:8080/student/list"

            }
            else{
                alert("用户名或密码错误");
            }
        })
    }



</script>
</body>
</html>